home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
- Begin VB.Form frmBooks
- BorderStyle = 1 'Fixed Single
- Caption = "Books Database"
- ClientHeight = 3345
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 6165
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3345
- ScaleWidth = 6165
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton cmdAll
- Caption = "Show All Records"
- Height = 375
- Left = 120
- TabIndex = 2
- Top = 2880
- Width = 2775
- End
- Begin VB.CommandButton cmdLetter
- Caption = "A"
- Height = 375
- Index = 0
- Left = 120
- TabIndex = 1
- Top = 2400
- Width = 1455
- End
- Begin VB.Data datBooks
- Caption = "Books"
- Connect = "Access"
- DatabaseName = "c:\VBDB\Working\Biblio.mdb"
- DefaultCursorType= 0 'DefaultCursor
- DefaultType = 2 'UseODBC
- Exclusive = 0 'False
- Height = 300
- Left = 3000
- Options = 0
- ReadOnly = 0 'False
- RecordsetType = 1 'Dynaset
- RecordSource = ""
- Top = 2880
- Width = 3015
- End
- Begin MSDBGrid.DBGrid grdBooks
- Bindings = "Example5-2.frx":0000
- Height = 2175
- Left = 0
- OleObjectBlob = "Example5-2.frx":0013
- TabIndex = 0
- Top = 120
- Width = 6135
- End
- Attribute VB_Name = "frmBooks"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Dim SQLAll As String
- Private Sub cmdAll_Click()
- 'Show all records
- datBooks.RecordSource = SQLAll + "ORDER BY Authors.Author"
- datBooks.Refresh
- End Sub
- Private Sub cmdLetter_Click(Index As Integer)
- If Index <> 25 Then
- 'Key other than Z clicked
- 'Append to SQLAll to limit records to letter clicked
- datBooks.RecordSource = SQLAll + "AND Authors.Author > '" + cmdLetter(Index).Caption + " ' "
- datBooks.RecordSource = datBooks.RecordSource + "AND Authors.Author < '" + cmdLetter(Index + 1).Caption + " ' "
- 'Z Clicked
- 'Append to SQLAll to limit records to Z Authors
- datBooks.RecordSource = SQLAll + "AND Authors.Author > 'Z' "
- End If
- datBooks.RecordSource = datBooks.RecordSource + "ORDER BY Authors.Author"
- datBooks.Refresh
- End Sub
- Private Sub Form_Activate()
- 'Show all records initially
- Call cmdAll_Click
- End Sub
- Private Sub Form_Load()
- Dim I As Integer
- 'Size search buttons
- cmdLetter(0).Width = (frmBooks.ScaleWidth - 2 * cmdLetter(0).Left) / 26
- 'Create 25 new buttons
- 'Position new button next to prior button
- For I = 1 To 25
- Load cmdLetter(I)
- cmdLetter(I).Left = cmdLetter(I - 1).Left + cmdLetter(0).Width
- cmdLetter(I).Caption = Chr(Asc("A") + I)
- cmdLetter(I).Visible = True
- Next I
- 'Build basic SQL statement
- SQLAll = "SELECT Authors.Author,Titles.Title,Publishers.[Company Name] "
- SQLAll = SQLAll + "FROM Authors, Titles, Publishers, [Title Author] "
- SQLAll = SQLAll + "WHERE Titles.ISBN = [Title Author].ISBN "
- SQLAll = SQLAll + "AND Authors.Au_ID = [Title Author].Au_ID "
- SQLAll = SQLAll + "AND Titles.PubID = Publishers.PubID "
- End Sub
-